package com.sdf.com.mvp_rx_retraft;

import android.app.Application;
import android.content.Context;

import com.orhanobut.logger.LogLevel;
import com.orhanobut.logger.Logger;
import com.sdf.com.mvp_rx_retraft.utils.AndroidUtil;
import com.sdf.com.mvp_rx_retraft.utils.ToastUtils;
import com.sdf.com.mvp_rx_retraft.utils.log.CrashHandler;

/**
 * Created by guangjiego on 2016/12/1.
 */

public class MyApplication extends Application {
    private static MyApplication instance;
    public static String cacheDir = "";

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        //日志初始化
        Logger.init().setLogLevel(LogLevel.FULL);
        //弹框其实初始化
        ToastUtils.register(this);
        //初始化日志输出工具
        CrashHandler.init(new CrashHandler(getApplicationContext()));
        /**
         * 如果存在SD卡则将缓存写入SD卡,否则写入手机内存
         */
        if (getApplicationContext().getExternalCacheDir() != null && AndroidUtil.isExistSDCard()) {
            cacheDir = getApplicationContext().getExternalCacheDir().toString();

        } else {
            cacheDir = getApplicationContext().getCacheDir().toString();
        }

    }

    // 获取ApplicationContext
    public static Context getContext() {
        return instance;
    }


}
